using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Services.Initial.Extensions;
using Services.Identity.Domain.Entities;

namespace Services.Identity.Infrastructure;
public class MyIdentityDbContext : IdentityDbContext<User, Role, long>
{
    public DbSet<UserPermission> Permissions { get; private set; }
    public DbSet<UserMessage> Messages { get; private set; }
    public MyIdentityDbContext(DbContextOptions<MyIdentityDbContext> dbContextOperations) : base(dbContextOperations)
    {
    }
    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);
        builder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
        builder.MyEnableSoftDeletionGlobalFilter();
    }
}
public class IdentityDbContextDesignTime : IDesignTimeDbContextFactory<MyIdentityDbContext>
{
    public MyIdentityDbContext CreateDbContext(string[] args)
    {
        var optionBuilder = DbContextOptionsBuilderFactory.Create<MyIdentityDbContext>();
        return new MyIdentityDbContext(optionBuilder.Options);
    }
}